package com.att.action;

import com.adkfp.utils.LayuiUtil;
import com.att.bean.UserInfoBean;
import com.att.service.UserInfoService;
import com.mysql.jdbc.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("userInfo")
public class UserInfoAction {

    @Resource(name = "userInfoService")
    private UserInfoService userInfoService;

    /**
     * Description:
     */
    @RequestMapping("selectAll")
    @ResponseBody
    public Object selectAll(UserInfoBean bean) {
        List<UserInfoBean> list = userInfoService.findByCondition(bean);
        long count = userInfoService.findByConditionCount(bean);
        return LayuiUtil.data(count, list);
    }


    /**
     * Description:
     */
    @RequestMapping("selectUserName")
    @ResponseBody
    public Object selectUserName(String depId) {
        List<UserInfoBean> list = new ArrayList<>();
        if(!StringUtils.isNullOrEmpty(depId)){
            list = userInfoService.findUserName(depId);
        }
        return list;
    }
}
